<template>
	<view>
		<view class="container">
			<uni-card :is-shadow="false" is-full>
				
			</uni-card>
			
			<uni-list>
				<uni-list-item title="计划编号" :rightText="formCode" />
				<uni-list-item title="线路" :rightText="line" />
				<uni-list-item title="登记车站" :rightText="regiserByStation" />
				<uni-list-item title="作业区段" :rightText="workSection" />
				<uni-list-item title="施工内容" :rightText="workContent" />
				<uni-list-item title="更新时间" :rightText="formDate" />
				<uni-list-item title="施工负责人" :rightText="manageBy" />
			</uni-list>
			
			<view style="margin-top: 30px;">
				<uni-button style="background-color: #3CB371; height: 30px; line-height: 30px; font-size: 14px; padding: 0 10px;"@click = "confirmConstruction" >施工点单确认</uni-button>
			</view>
		</view>
	</view>
</template>

<script>
	
export default {
	data() {
		return {
			formCode: "", // 从数据库获取的计划编号
			line: "", // 从数据库获取的线路
			regiserByStation: "", // 从数据库获取的车站
			workSection: "", // 从数据库获取的施工范围
			workContent: "", // 从数据库获取的施工内容
			formDate: "", // 从数据库获取的更新时间
			manageBy: "" ,// 从数据库获取的施工负责人
			id: ""
		}
	},
	methods: {
		confirmConstruction() {
			// 确认施工点单的逻辑代码
			uni.navigateTo({
			  url: '/pages/orderinfo2/orderinfo2?id=' + this.id  // 替换为你的目标页面路径
			});
		},
		
		fetchDataFromBackend() {
			
			uni.request({
				url: `http://localhost:82/constructionRequestBase/management/${this.id}`, // 替换为实际的后端API地址
				method: 'GET',
				success: (res) => {
					console.log(res.data);
					// 从后端成功获取数据后，更新前端数据
					this.formCode = res.data.data.formCode;
					this.line = res.data.data.lineText;
					this.regiserByStation = res.data.data.regiserByStation;
					this.workSection = res.data.data.workSection;
					this.workContent = res.data.data.workContent;
					this.formDate = res.data.data.formDate;
					this.manageBy = res.data.data.manageBy;
				},
				fail: (err) => {
				   console.error('Failed to fetch data from backend:', err);
				},
			});
		}
	},
	
	created() {
		this.id = this.$route.query.id
		console.log(this.id)
		this.fetchDataFromBackend(); // 在组件创建时从后端获取数据
	}
}
</script>

<style>

</style>